import request from '@/api/axios'
import {AxiosPromise} from 'axios'
import {DataRes} from '@/api/config'
import {BasePhysicalExamination} from './index'

/**
 * @description: 表单属性
 * @return {*}
 */
export interface VisceraFunction extends BasePhysicalExamination {
  oralCavity: string // 口唇
  dentalArch: string //齿列复选
  dentalArchCheckboxs: string[] // 齿列
  hypodontia: string, // 缺齿
  caries: string, // 龋齿
  denlture: string, // 义齿（假牙）
  pharynxState: string // 咽部,
  eyesLeft: undefined | number // 视力（左)
  eyeRight: undefined | number // 视力（右)
  recEyeLeft: undefined | number // 矫正视力(左)
  recEyeRight: undefined | number // 矫正视力(右)
  hearingState: string // 听力
  motorFuncState: string // 运动功能
}

// 摘除后端不要的属性
export type VisceraFunctionParams = Omit<VisceraFunction, 'dentalArchCheckboxs'>

/**
 * @description: 保存脏器功能
 * @param {VisceraFunction} data
 * @return {*}
 */
export const saveVisceraFunction = (data: VisceraFunctionParams): AxiosPromise<DataRes<undefined>> => {
  return request({
    url: '/api/visceraFunction/save',
    method: 'post',
    data
  })
}

/**
 * @description: 根据体检登记表id获取脏器功能数据
 * @param {string} checkupRegisterId
 * @return {*}
 */
export const getVisceraFunction = (checkupRegisterId: string): AxiosPromise<DataRes<VisceraFunction>> => {
  return request({
    url: `/api/visceraFunction/get/${checkupRegisterId}`,
    method: 'get'
  })
}

/**
 * @description: 拒检脏器功能
 * @param {BasePhysicalExamination} data
 * @return {*}
 */
export const rejectVisceraFunction = (data: BasePhysicalExamination): AxiosPromise<DataRes<undefined>> => {
  return request({
    url: '/api/visceraFunction/reject',
    method: 'post',
    data
  })
}
